package logic

import (
	"context"

	"go-zero-mall/app/admin/cmd/rpc/internal/svc"
	"go-zero-mall/app/admin/cmd/rpc/pd"
	"go-zero-mall/app/admin/model"

	"github.com/jinzhu/copier"
	"github.com/zeromicro/go-zero/core/logx"
)

type MenuUpdateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMenuUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MenuUpdateLogic {
	return &MenuUpdateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 菜单-更新
func (l *MenuUpdateLogic) MenuUpdate(in *pd.UmsMenuUpdateReq) (*pd.UmsMenuUpdateResp, error) {
	var d model.UmsMenu
	copier.Copy(&d, in)
	err := l.svcCtx.UmsMenuModel.Update(l.ctx, &d)
	if err != nil {
		return nil, err
	}
	return &pd.UmsMenuUpdateResp{}, nil
}
